<script setup lang="ts">
import { ref, defineProps } from "vue";
import { formRules } from "./rule";
import { FormProps } from "./types";
import * as Contanst from "../../contanst";
const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    type: "",
    title: "",
    content: ""
  })
});

const ruleFormRef = ref();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

function onChange() {
  // console.log(newFormInline.title);
}

defineExpose({ getRef });
</script>

<template>
  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="82px"
  >
    <el-form-item label="分类" prop="type">
      <el-select
        v-model="newFormInline.type"
        placeholder="请选择分类"
        class="!w-[160px]"
        @change="onChange"
      >
        <el-option
          v-for="item in Contanst.typeOptions"
          :key="item"
          :label="item"
          :value="item"
        />
      </el-select>
    </el-form-item>
    <el-form-item label="标题" prop="title">
      <el-input
        v-model="newFormInline.title"
        clearable
        placeholder="请输入标题"
      />
    </el-form-item>
    <el-form-item label="内容">
      <el-input
        v-model="newFormInline.content"
        placeholder="请输入内容"
        type="textarea"
      />
    </el-form-item>
    <!--  <el-form-item label="关键词" prop="title">
      <el-input
        v-model="newFormInline.title"
        clearable
        placeholder="请输入关键词"
      />
    </el-form-item> -->
    <!--  <el-form-item label="摘要">
      <el-input
        v-model="newFormInline.content"
        placeholder="请输入摘要"
        type="textarea"
      />
    </el-form-item> -->
  </el-form>
</template>
